using System;
using System.Collections.Generic;

namespace Core.Demo1
{
	public class IncrementService
	{
		public void HikePay(IEnumerable<Employee> employees)
		{
			foreach (var employee in employees)
			{
				employee.IncrementSalary(500);
				employee.LastIncrementDate = DateTime.Now;
			}
			ReportEmployeeListWhoseSalaryIsRevised(employees);
		}

		private void ReportEmployeeListWhoseSalaryIsRevised(IEnumerable<Employee> enumerable)
		{
			//Generate report
		}

        
		public class Employee
		{
			public double Salary { get; set; }
			public Guid Id { get; set; }
			public string Name { get; set; }
			public DateTime? LastIncrementDate { get; set; }

			public void IncrementSalary(double amount)
			{
				if (LastIncrementDate == null 
					|| LastIncrementDate.Value < DateTime.Now.AddYears(-1))
				{
					Salary += amount;
				}
			}
		}




















		public void HikePay1(IEnumerable<Employee> employees)
		{
			var uniqueEmployees = new List<Employee>();
			foreach (var employee in employees)
			{
				employee.IncrementSalary(500);
				employee.LastIncrementDate = DateTime.Now;

				if (!uniqueEmployees.Contains(employee))
					uniqueEmployees.Add(employee);
			}
			ReportEmployeeListWhoseSalaryIsRevised(uniqueEmployees);
		}































		public void HikePay2(IEnumerable<Employee> employees)
		{
			foreach (var employee in employees)
			{
				employee.IncrementSalary(500);
				employee.LastIncrementDate = DateTime.Now;
			}
			var uniqueEmployees = GetUniqueEmployeeList(employees);
			ReportEmployeeListWhoseSalaryIsRevised(uniqueEmployees);
		}


		public IEnumerable<Employee> GetUniqueEmployeeList(IEnumerable<Employee> employees)
		{
			throw new NotImplementedException();

			var uniqueEmployees = new List<Employee>();
			foreach (var employee in employees)
			{
				if (!uniqueEmployees.Contains(employee))
					uniqueEmployees.Add(employee);
			}
			return uniqueEmployees;
		}

	}
}